package com.game.comment.core;

import java.util.HashMap;

/**
 * 操作消息提醒
 *
 * @author cxy
 */

public class AjaxResult extends HashMap<String, Object>
{

    ////////////////////////////////////////////////////////////////////////////////////////////////
    public static final String RESULT_TAG = "result";
    //////////////////////////
    public static final int SIG_ERR = -2;
    public static final int NORMAL = 1;
    public static final int FAIL = 0;
    ////////////////////////////////////////////////////////////////////////////////////////////////
    public static final String MESSAGE_TAG = "msg";
    /////////////////////////
    public static final String SUCCESS_MSG = "success";
    public static final String FAIL_MSG = "fail";
    public static final String ERROR_MSG = "error";
    ////////////////////////////////////////////////////////////////////////////////////////////////
    public static final String DATA_TAG = "data";
    ////////////////////////////////////////////////////////////////////////////////////////////////

    public AjaxResult() {}
    public AjaxResult(int result,String msg)
    {
        super.put(RESULT_TAG, result);
        super.put(MESSAGE_TAG, msg);
    }
    public AjaxResult(int result,String msg ,Object data)
    {
        super.put(RESULT_TAG, result);
        super.put(MESSAGE_TAG, msg);
        super.put(DATA_TAG, data);
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////
    public static AjaxResult success()
    {
        return new AjaxResult(NORMAL,SUCCESS_MSG,null);
    }
    public static AjaxResult success(String msg)
    {
        return new AjaxResult(NORMAL,msg,null);
    }
    public static AjaxResult success(Object data)
    {
        return new AjaxResult(NORMAL,SUCCESS_MSG,data);
    }
    public static AjaxResult success(String msg,Object data)
    {
        return new AjaxResult(NORMAL,msg,data);
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////

    public static AjaxResult fail()
    {
        return new AjaxResult(FAIL,FAIL_MSG,null);
    }
    public static AjaxResult fail(String msg)
    {
        return new AjaxResult(FAIL,msg,null);
    }
    public static AjaxResult fail(Object data)
    {
        return new AjaxResult(FAIL,FAIL_MSG,data);
    }
    public static AjaxResult fail(String msg,Object data)
    {
        return new AjaxResult(FAIL,msg,data);
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////
    public static AjaxResult error()
    {
        return new AjaxResult(SIG_ERR,ERROR_MSG,null);
    }
    public static AjaxResult error(String msg)
    {
        return new AjaxResult(SIG_ERR,msg,null);
    }
    public static AjaxResult error(Object data)
    {
        return new AjaxResult(SIG_ERR,ERROR_MSG,data);
    }
    public static AjaxResult error(String msg,Object data)
    {
        return new AjaxResult(SIG_ERR,msg,data);
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////
    @Override
    public AjaxResult put(String key, Object value)
    {
        super.put(key, value);
        return this;
    }
}
